ssh-agent /bin/bash
ssh-add ~/.ssh/id_rsa 
export HASTHI_HOME=`pwd`
cd $HASTHI_HOME

#SERVICE_COUNTS="200 400 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000"
#MANGER_COUNTS="1,1000 5,5000 10,6000 20,8000 50,15000"
SERVICE_COUNTS="200 400"
MANGER_COUNTS="1,1500"

for md in ${MANGER_COUNTS}; do
	for sc in ${SERVICE_COUNTS}; do
		mc=`echo $md|cut -f1 -d','`
		maxsc=`echo $md|cut -f2 -d','`
		
		#shutdown and restart the bootstrap node
		#ssh linbox3 /u/hperera/svncode/management/target/dist-bin/bootstrap.sh 
		./clean.sh &
		#Copy process PID
		PID_C1=`echo ${!}`
		sleep 10s

		if [ "$sc" -le $maxsc ]; then
			LOG_DIR=/u/hperera/logs/hasthi_${sc}_${mc}_`date +%m_%d_%H_%M`
			echo $LOG_DIR
			mkdir $LOG_DIR
			cmd1="srun -N $((1+$sc/200)) serviceset.sh 200 $LOG_DIR"
			cmd2="srun -N ${mc} testMngeNode.sh $HASTHI_HOME/hasthi.properties $HASTHI_HOME $LOG_DIR"
			echo $cmd1 $cmd2
			$cmd1 &
			PID_C2=`echo ${!}`
			$cmd2
			#srun -N $(($sc/200)) serviceset.sh 200 $LOG_DIR &
			#srun -N ${mc} testMngeNode.sh $HASTHI_HOME/hasthi.properties $HASTHI_HOME $LOG_DIR
			#Following wait for all child processes to complete 
			wait $PID_C2
			kill  $PID_C1
			echo $mc $sc "<" $maxsc " Done"
			 
		else	
			echo $mc $sc "<" $maxsc " Ignored"
		fi			
	done
done 

